package com.oe.dubbo;



import com.oe.monitor.TPMonitor;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
import org.apache.dubbo.rpc.*;

@Activate(group = {CommonConstants.CONSUMER})
public class TPMonitorFilter implements Filter {


    public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
        long start = System.currentTimeMillis();
        Result ret = invoker.invoke(invocation);
        long end = System.currentTimeMillis();
        TPMonitor.getTpMonitor().collect(invocation.getServiceName()+"."+invocation.getMethodName(),end-start);
        return ret;
    }
}
